package com.tianshi.product.service.impl;


import com.tianshi.entity.Categories;
import com.tianshi.product.mapper.CategoryMapper;
import com.tianshi.product.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;


    @Override
    public Categories getCategoryById(Long id) {
        return categoryMapper.getCategoryById(id);
    }

    @Override
    public List<Categories> getAllCategory() {
        return categoryMapper.getAllCategory();
    }

    @Override
    public Long addCategory(Categories categories) {
        return categoryMapper.addCategory(categories);
    }

    @Override
    public Categories updateCategory(Categories category) {
        Long updateCategoryId = categoryMapper.updateCategory(category);
        Categories updateCategory = categoryMapper.getCategoryById(updateCategoryId);
        return updateCategory;
    }

    @Override
    public Long deleteCategory(Long id) {
        Long deleteCategoryId = categoryMapper.deleteCategory(id);
        return deleteCategoryId;
    }
}
